home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Archives
/
ForCLI
/
sum.lha
/
sum.doc
< prev
Wrap
Text File
|
1994-04-03
|
4KB
|
137 lines
$VER: Sum V1.1
Written by Oliver Kaufmann
Released on April 3, 1994
This program is Freeware. Copyright 1994 by Oliver Kaufmann.
All Rights Reserved. SUM is freely distributable, but the author retains all
rights in regards to the program. Permission is granted to distribute this
program for a minimal charge (for copying, handling, etc.).
Use this program at your own risk, no warranties will be made.
SUM is a Shell-command which sums up numbers in formated files.
SUM takes its input either from stdin or from a file or a list of files.
Its output will give the sum of all numbers at the specified position in every
line of the specified file(s).
1. INSTALLATION
---------------
Copy SUM to any directory you like that is in your path.
I. USAGE
--------
usage: sum [-h|-?] [<filepatternlist>] [-p<pos>] [-q]
-h : show usage
-? : show usage
<filepatternlist> : one or more files or filepatterns,
if omitted, use stdin as input
-p<pos> : start at position <pos> in every line
-q : quiet, do not display verbose information
II. WHAT IS IT FOR
------------------
Suppose you've got a lot of tar archives on streamer tapes. For every archive
you keep a index file which might have been produces by tar tvf tape:
It will look like:
-rw------- 0/0 53 Jan 27 12:04 1994 .run.log
drwx------ 0/0 0 Feb 28 19:34 1994 alt/
drwx------ 0/0 0 Mar 13 20:58 1994 alt/binaries/
drwx------ 0/0 0 Mar 13 20:13 1994 alt/binaries/pictures/
drwx------ 0/0 0 Feb 26 20:33 1994 alt/binaries/pictures/misc/
-rw------- 0/0 11319 Feb 25 22:49 1994 alt/binaries/pictures/misc/DFC06.gif
-rw------- 0/0 14456 Feb 25 22:49 1994 alt/binaries/pictures/misc/DFC08.gif
-rw------- 0/0 13058 Feb 25 22:49 1994 alt/binaries/pictures/misc/DFC07.gif
-rw------- 0/0 45922 Feb 25 22:49 1994 alt/binaries/pictures/misc/FROG.JPG
-rw------- 0/0 13290 Feb 25 22:49 1994 alt/binaries/pictures/misc/MARSAPP.JPG
-rw------- 0/0 45280 Feb 25 22:49 1994 alt/binaries/pictures/misc/juliaidx.gif
-rw------- 0/0 14737 Feb 25 22:50 1994 alt/binaries/pictures/misc/EINSTEIN.JPG
-rw------- 0/0 195220 Feb 25 22:50 1994 alt/binaries/pictures/misc/Monet_Willows.jpg
-rw------- 0/0 1348705 Feb 25 22:50 1994 alt/binaries/pictures/misc/ipal2.zip
. ^
. |
. -- position 14
In the case you want to restore an archive or at least a part of it,
you probabliy want to know how much data is in that archive. You may do it by
hand and get crazy, or you can use SUM.
III. HOW IT WORKS
-----------------
SUM takes its input, jumps to the specified position, reads the number,
adds it to the sum and carries on till there are no more lines or files.
Then it will print out what has been totaled up.
Be aware that all arguments to switches must be directly typed after the
switch, no spaces in between. If reading from stdin without redirection you
finish typing by pressing CTRL-\.
IV. EXAMPLES
-------------
Type sum and enter some numbers. Then press CTRL-\.
:> sum
:<- 1
:<- 2
:<- 'CTRL-\'
:-> --------------------------------------------------------------------------
:-> 0 file(s) total : 3 in 2 lines at column 0
Now you can do
:> list NOHEAD >ram:test.idx
:> sum ram:test.idx -p23
:> sum i*
etc.
Just play around to find out how it works.
2. Inspiration
--------------
I use this program because I do have tar archives. I use it to calculate
how much data is in the archives and how much space do I need, if I want to
extract some files from an archive.
3. Misc
-------
This program is far from complete and has not been tested too much, but it
works for me.
4. Source
---------
I've included the source code. Everybody may use it, implement other
features etc. as long as the author is mentioned.
5. The Author
-------------
Oliver Kaufmann
Eserwallstrasse 8
86159 Augsburg
Germany e-mail: kaufmano@informatik.tu-muenchen.de
DISCLAIMER: Use this program at your own risk.